package io.kiki.sba.registry.common.model.elector;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Objects;


@Setter
@Getter
public class Leader implements Serializable {
    private static final long serialVersionUID = 1L;
    private final String leader;
    private final long epoch;

    public Leader(String leader, long epoch) {
        this.leader = leader;
        this.epoch = epoch;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        Leader that = (Leader) o;
        return epoch == that.epoch && Objects.equals(leader, that.leader);
    }

    @Override
    public int hashCode() {
        return Objects.hash(epoch, leader);
    }


}
